/*
 * Copyright (c) 2011, INRIA
 * All rights reserved.
 */
package fr.inria.wimmics.semanticweb.filter.type;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.gephi.filters.spi.FilterProperty;

/**
 *
 * @author Erwan Demairy <Erwan.Demairy@inria.fr>
 */
public class TypeFilterPanel extends javax.swing.JPanel implements ActionListener {

    private final TypeFilter filter;

    public TypeFilterPanel(TypeFilter filter) {
        this.filter = filter;
        initComponents();
        typeField.addActionListener(this);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        FilterProperty typeToFilter = filter.getProperties()[0];
        typeToFilter.setValue(typeField.getText());
    }

    /**
     * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        typeField = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();

        typeField.setText(org.openide.util.NbBundle.getMessage(TypeFilterPanel.class, "TypeFilterPanel.typeField.text")); // NOI18N

        jLabel1.setText(org.openide.util.NbBundle.getMessage(TypeFilterPanel.class, "TypeFilterPanel.jLabel1.text")); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(typeField, javax.swing.GroupLayout.DEFAULT_SIZE, 264, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(typeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JTextField typeField;
    // End of variables declaration//GEN-END:variables
}
